
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<link href="${ctx}/css/pass.css" rel="stylesheet">
<script type="text/javascript">
	/*树形表格设置*/
	var setting = {
			check: {
				enable: true,
				chkStyle: "radio",
				radioType: "all"
			},
			view: {
				dblClickExpand: false
			},
			
			  data: {
				  key :{
						name:"columnName",
					},
		    	 simpleData: {//简单数据模式
			     	 enable:true,
			      	 idKey: "id",
			     	 pIdKey: "parentId",
			    	 rootPId: null
		  	  }
		 	 },
			callback: {
				onClick: onClick,
				onCheck: onCheck
			}
	};
	
	
	
	function onClick(e, treeId, treeNode) {
		e.preventDefault();
		var zTree = $.fn.zTree.getZTreeObj("permissionZtree");
		zTree.checkNode(treeNode, !treeNode.checked, null, true);
		return false;
	}	
	
	function onCheck(e, treeId, treeNode) {
			var zTree = $.fn.zTree.getZTreeObj("permissionZtree"),
			nodes = zTree.getCheckedNodes(true),
			v = "";
			pId = "";
			for (var i=0, l=nodes.length; i<l; i++) {
				v += nodes[i].columnName + ",";
				pId += nodes[i].id + ",";
			}
			if (v.length > 0 ) v = v.substring(0, v.length-1);
			if (pId.length > 0 ) pId = pId.substring(0, pId.length-1);
			var parentName = $("#parent_name");
			var parentId = $("#parentId");
			parentName.attr("value", v);
			parentId.attr("value",pId)
			hideMenu();
			console.log("v的值为"+v);
			console.log("parentName的值为"+parentName);
	}
	
	function showPermissonList(){
		
		console.log("点击方法调用开始");
		var parentName = $("#parent_name");
		var offset = $("#parent_name").offset();
		console.log("parentName的值为"+parentName);
		console.log("offfset的值为"+offset);
		$("#content").slideDown("fast");
		console.log("点击方法调用结束");
		 $("body").bind("mousedown", onBodyDown);
	}
	
	function hideMenu() {
			$("#content").fadeOut("fast");
			$("body").unbind("mousedown", onBodyDown);
	}
	
 	function onBodyDown(event) {
			if (!(event.target.id == "menuBtn" || event.target.id == "parent_name" || event.target.id == "content" || $(event.target).parents("#content").length>0)) {
				hideMenu();
			}
	}

	function onLoadZTree(){
	     var t = $("#permissionZtree");
		 console.log("t的值"+t);
	  	 t = $.fn.zTree.init(t, setting, ${treeNodes}).expandAll(true); 
	  	 console.log("进入onloadzTreee");
	  	 console.log("treeNodes的值"+${treeNodes});
	  	 console.log("t的值"+t);
	} 
	
	function setAttr(){
	 if("add"==$('#op').val()){
			$('#is_used').attr("disabled","disabled");
		}else{
			$('#is_used').removeAttr();
		}	
	 console.log("进入setAttr");
	}
	$(document).ready(function(){
		onLoadZTree();
		setAttr();
	
	});
</script>
<div class="bjui-pageContent">
	<form action="${ctx}/sys/sysColumnAction/doSave" class="ajaxForm"
		data-toggle="validate" enctype="multipart/form-data">
		<input type="hidden" name="ctxPath" id="ctx_path" value="${ctx}">
		<input type="hidden" id="op" name="op" value="${param.op}${op}">
		<%--  <c:if test="${!empty permission}"> --%>
		<input type="hidden" name="id" id="id" value="${column.id}"> <input
			type="hidden" name="parentId" id="parentId"
			value="${column.parentId}">

		<%--     <input type="hidden" name="createUser" id="createUser" value="${column.createUser}"> --%>

		<input type="hidden" name="status" id="status"
			value="${column.status}">
		<%--  <input  name="open" id="open" value="${permission.open}"> --%>
		<%--     </c:if> --%>
		<table class="table table-condensed table-hover">
			<tbody>
				<tr>
					<td colspan="2" align="center" valign="middle"><h4>${title}</h4></td>
				</tr>
				<tr style="width: 300px;">
					<td><label for="name" class="control-label x90">栏目名称：</label>
						<input class="" id="columnName" type="text" name="columnName"
						value="${column.columnName}"
						data-rule="required;name;remote[${ctx}/bus/passBasColumnAction/doNameValidate?op=${op}&original=${column.columnName}]" />
					</td>
					<td><label for="url" class="control-label x90">栏目关键词：</label>
						<input class="" id="url" type="text" name="keyWords"
						value="${column.keyWords}" data-rule="required;" /></td>


				</tr>
				<tr>
					<td><label for="parent_name" class="control-label x90">父栏目名称：</label>
						<input class="m_readonly" id="parent_name" type="text"
						name="parentName" readonly value="${column.parentName}"
						onclick="showPermissonList()" />
						<div id="content" class="m_ztree_content"
							style="display: none; position: absolute;">
							<ul id="permissionZtree" class="ztree"
								style="margin-top: 0; width: 160px;"></ul>
						</div></td>
					<td><label for="sys_id" class="control-label x90">链接地址：</label>
						<input class="" id="sys_id" type="text" name="linkUrl"
						value="${column.linkUrl}" /></td>
				</tr>
				<tr>
					<td><label for="seq_idx" class="control-label x90">栏目排序：</label>
						<input class="" id="seq_idx" type="number" name="seqIdx"
						value="${column.seqIdx}" data-rule="required;" /></td>
							<td><label for="seq_idx" class="control-label x90">栏目类型：</label>
							 <select id="j_dialog_type_id" name="columnType" data-toggle="selectpicker">
                        	<c:forEach items="${code}"  var="c">
                        		<c:choose>
                        			<c:when test="${column.columnType==c.codeName&&c.codeType=='columnType'}">
                        				<option value="${c.codeName}" selected="selected">${c.codeName}</option>
                        			</c:when>
                        			<c:when test="${c.codeType=='columnType'}">
                        				<option value="${c.codeName}" >${c.codeName}</option>
                        			</c:when>
                        		</c:choose>
                        	</c:forEach>
                        </select>
				</tr>
				<tr>
					<td ><label for="description"
						class="control-label x90">是否展示：</label> 
						 <select id="j_dialog_type_id" name="display" data-toggle="selectpicker">
                        <%-- 	<c:forEach items="${code}"  var="c">
                        		<c:choose>
                        			<c:when test="${c.codeValue==0}">
                        				<option value="${c.codeValue}" selected="selected">${c.codeName}</option>
                        			</c:when>
                        			<c:when test="${c.codeType=='signType'}">
                        				<option value="${c.codeValue}" >${c.codeName}</option>
                        			</c:when>
                        		</c:choose>
                        	</c:forEach> --%>
                        		<c:choose>
                        			<c:when test="${column.display=='0'}">
                        				<option value="0" selected="selected">是</option>
                        				<option value="1" >否</option>
                        			</c:when>
                        			<c:when test="${column.display=='1'}">
                        				<option value="1" selected="selected" >否</option>
                        				<option value="0" >是</option>
                        			</c:when>
                        			   <c:otherwise> 
    						<option value="0" >是</option>
    						<option value="1" >否</option>
                           </c:otherwise>
                        		</c:choose>
                        </select>
					</td>
						<td ><label for="description"
						class="control-label x90">是否在新窗口  展示：</label> 
						<select id="j_dialog_type_id" name="isNewWindow" data-toggle="selectpicker">
                        		<c:choose>
                        		<c:when test="${column.isNewWindow=='0'}"> 
                        				<option value="0" selected="selected">是</option>
                        					<option value="1" >否</option>
                        			</c:when>
                        			<c:when test="${column.isNewWindow=='1'}">
                        				<option value="1" selected="selected">否</option>
                        				<option value="0" >是</option>
                        			</c:when> 
                        			 <c:otherwise> 
    						<option value="0" >是</option>
    						<option value="1" >否</option>
                           </c:otherwise>
                        		</c:choose>
                        		
                        </select>
					</td>
				</tr>
				<tr>
					<td colspan="2"><label for="sys_id"
						class="control-label x90">栏目图标地址：</label> <input class=""
						id="imageUrl" type="text" name="imageUrl" readonly="readonly"
						value="${column.imageUrl}" /> <input type="file" name="file"
						accept="image/*" style="width: 40%;"></td>
				</tr>
				<tr>
					<td colspan="2"><label for="description"
						class="control-label x90">栏目描述：</label> <textarea
							name="description" id="description" rows="5" cols="58">${column.description}</textarea>
					</td>
				</tr>
			</tbody>
		</table>
	</form>
</div>
<div class="bjui-pageFooter">
	<ul>
		<li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
		<li><button type="submit" class="btn-default" data-icon="save">保存</button></li>
	</ul>
</div>